using System.Collections.Generic;
using System.Linq;
using Godot;

namespace Arcane.Source.Data
{
    public class CharacterDB
    {
        private readonly Dictionary<StringName, CharacterData> _data = [];

        public IEnumerable<KeyValuePair<StringName, CharacterData>> Data => _data.AsEnumerable();

        public void Load(string loadDir)
        {
            LoadUtil.LoadRecursive<CharacterRes>(
                loadDir,
                (name, res) => _data.Add(name, new(res)),
                file => file.EndsWith("res")
            );
        }

        #if DEBUG
        public void PrintDataNames()
        {
            foreach (var name in _data.Keys)
            {
                GD.Print(name);
            }
        }
        #endif
    }
}